package com.jsp.app.controller;

import com.jsp.app.service.LoginService;
import com.tamll.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;


    @GetMapping("/login")
    public String Login(){
        return "fore/loginPage";
    }


    @Autowired
    private RestTemplate restTemplate;

    @ResponseBody
    @GetMapping("/doLogin")
    public User toLogin(String username, String password){
        Map<String,String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        String url = "http://localhost:9019/login?username={username}&password={password}";
        return restTemplate.getForObject(url, User.class, map);
    }



}
